package com.ithema.service;


import com.github.pagehelper.PageInfo;
import com.itheima.domain.User;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import java.util.Date;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath:applicationContext.xml")
public class UserService {
    @Autowired
    private com.itheima.service.UserService userService;

    @Test
    public void testSave() {
        User user = new User();
        user.setUsername("sxl");
        user.setPassword("123");
        user.setGender(1);
        user.setRealName("属性");
        user.setBirthday(new Date());
        userService.save(user);
    }

    @Test
    public void testUpdate() {
        User user = new User();
        user.setUuid(2);
        user.setUsername("Jockme");
        user.setPassword("root");
        user.setRealName("JockIsMe");
        user.setGender(1);
        user.setBirthday(new Date(333333000000L));

        userService.update(user);
    }

    @Test
    public void testDelete() {
        userService.delete(1);
    }

    @Test
    public void testGet() {
        User user = userService.findById(2);
        System.out.println(user);
    }

    @Test
    public void testGetAll() {
        PageInfo<User> all = userService.findAll(2,2);
        System.out.println(all);
        System.out.println(all.getList().get(0));
        System.out.println(all.getList().get(1));
    }

    @Test
    public void testLogin() {
        User user = userService.login("Jockme", "root");
        System.out.println(user);
    }
}
